#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
const int N = 100010, M = 1000010;

int T;
LL n, m, L, V, last, cnt;
LL d[N], v[N], a[N], p[N];
LL hp[M], rr[M], r[M];
bool st[N];
vector <pair <LL, LL> > seg;

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    scanf("%d", &T);
    while (T -- )
    {
        last = cnt = 0;
        for (int i = 0; i < M; i ++ ) r[i] = rr[i] = hp[i] = 0;
        memset(st, false, sizeof st);
        seg.clear();

        scanf("%lld%lld%lld%lld", &n, &m, &L, &V);
        for (int i = 1; i <= n; i ++ ) scanf("%lld%lld%lld", &d[i], &v[i], &a[i]);
        for (int i = 1; i <= m; i ++ )
        {
            scanf("%lld", &p[i]);
            r[p[i]] = i, last = max(last, p[i]);
            rr[p[i]] = i;
        }
        int ran = 1;
        for (int i = 0; i < M; i ++ ) if (r[i]) hp[r[i]] = ran ++ ;
        for (int i = M - 5; i >= 0; i -- ) if (!r[i]) r[i] = r[i + 1];
        for (int i = 1; i < M - 5; i ++ ) if (!rr[i]) rr[i] = rr[i - 1];

        for (int i = 1; i <= n; i ++ )
        {
            if (!r[d[i]]) continue;
            if (a[i] == 0 && v[i] > V) st[i] = true, cnt ++ ;
            else if (a[i] > 0)
            {
                if (v[i] > V) st[i] = true, cnt ++ ;
                else if (V * V - v[i] * v[i] + 2 * a[i] * d[i] < last * 2 * a[i]) st[i] = true, cnt ++ ;
            }
            else if (a[i] < 0)
                if (v[i] * v[i] + 2 * a[i] * (p[r[d[i]]] - d[i]) > V * V) st[i] = true, cnt ++ ;
        }
        printf("%lld ", cnt);
        if (!cnt) {printf("%lld\n", m); continue; }

        for (int i = 1; i <= n; i ++ )
        {
            if (!st[i]) continue;
            if (a[i] == 0) seg.push_back({hp[r[d[i]]], m});
            else if (a[i] > 0)
            {
                LL P = max((LL)0, (V * V - v[i] * v[i]) / (2 * a[i])) + d[i] + 1;
                if (V < v[i]) P -- ;
                seg.push_back({hp[r[P]], m});
            }
            else
            {
                LL R = d[i] + (v[i] * v[i]) / (2 * -a[i]);
                if ((v[i] * v[i]) % (2 * -a[i]) == 0) R -- ;
                seg.push_back({hp[r[d[i]]], hp[rr[R]]});
            }
        }

        sort(seg.begin(), seg.end());
        LL res = 1, rmin = seg[0].second;
        for (int i = 1; i < seg.size(); i ++ )
        {
            if (seg[i].first > rmin) rmin = seg[i].second, res ++ ;
            else rmin = min(rmin, seg[i].second);
        }
        printf("%lld\n", m - res);
    }

    return 0;
}













